package com.home.customtest.typehandle;

import com.custom.jdbc.handler.AbstractTypeHandler;
import com.home.customtest.enums.SexEnum;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * @author XiaoBai
 * @since 2024/4/17 14:35
 */
public class SexEnumTypeHandler extends AbstractTypeHandler<SexEnum> {
    @Override
    public SexEnum getTypeValue(Object val) throws Exception {
        String i = String.valueOf(val);
        return SexEnum.findByDesc(i);
    }

    @Override
    public SexEnum getTypeValue(ResultSet rs, int index) throws Exception {
        return getTypeValue(rs.getObject(index));
    }

    @Override
    public void setTypeValue(PreparedStatement statement, int index, SexEnum val) throws Exception {

    }
}
